<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Heap (data structure)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Heap_(data_structure)"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.math.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Heap_data_structure rootpage-Heap_data_structure skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Heap (data structure)</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">For the memory heap (in low-level computer programming), which is unrelated to this data structure, see <a href="C_dynamic_memory_allocation" title="C dynamic memory allocation">C dynamic memory allocation</a>.</div>
<p>In <a href="Computer_science" title="Computer science">computer science</a>, a <b>heap</b> is a <a href="Tree_(data_structure)" class="mw-redirect" title="Tree (data structure)">tree</a>-based <a href="Data_structure" title="Data structure">data structure</a> that satisfies the <b>heap property</b>: In a <i>max heap</i>, for any given <a href="Node_(computer_science)" title="Node (computer science)">node</a> C, if P is the parent node of C, then the <i>key</i> (the <i>value</i>) of P is greater than or equal to the key of C. In a <i>min heap</i>, the key of P is less than or equal to the key of C.<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> The node at the "top" of the heap (with no parents) is called the <i>root</i> node.
</p><p>The heap is one maximally efficient implementation of an <a href="Abstract_data_type" title="Abstract data type">abstract data type</a> called a <a href="Priority_queue" title="Priority queue">priority queue</a>, and in fact, priority queues are often referred to as "heaps", regardless of how they may be implemented. In a heap, the highest (or lowest) priority element is always stored at the root. However, a heap is not a sorted structure; it can be regarded as being partially ordered. A heap is a useful data structure when it is necessary to repeatedly remove the object with the highest (or lowest) priority, or when insertions need to be interspersed with removals of the root node.
</p><p>A common implementation of a heap is the <a href="Binary_heap" title="Binary heap">binary heap</a>, in which the tree is a <a href="Binary_tree#Types_of_binary_trees" title="Binary tree">complete</a><sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> binary tree (see figure). The heap data structure, specifically the binary heap, was introduced by <a href="J._W._J._Williams" title="J. W. J. Williams">J. W. J. Williams</a> in 1964, as a data structure for the <a href="Heapsort" title="Heapsort">heapsort</a> sorting algorithm.<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup> Heaps are also crucial in several efficient <a href="Graph_algorithms" class="mw-redirect" title="Graph algorithms">graph algorithms</a> such as <a href="Dijkstra's_algorithm" title="Dijkstra's algorithm">Dijkstra's algorithm</a>. When a heap is a complete binary tree, it has the smallest possible height—a heap with <i>N</i> nodes and <i>a</i> branches for each node always has log<sub><i>a</i></sub> <i>N</i> height.
</p><p>Note that, as shown in the graphic, there is no implied ordering between siblings or cousins and no implied sequence for an <a href="Inorder_traversal" class="mw-redirect" title="Inorder traversal">in-order traversal</a> (as there would be in, e.g., a <a href="Binary_search_tree" title="Binary search tree">binary search tree</a>). The heap relation mentioned above applies only between nodes and their parents, grandparents. The maximum number of children each node can have depends on the type of heap.
</p><p>Heaps are typically constructed in-place in the same array where the elements are stored, with their structure being implicit in the access pattern of the operations. Heaps differ in this way from other data structures with similar or in some cases better theoretic bounds such as <a href="Radix_tree" title="Radix tree">radix trees</a> in that they require no additional memory beyond that used for storing the keys.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Operations">Operations</h2></div>
<p>The common operations involving heaps are:
</p>
<dl><dt>Basic</dt></dl>
<ul><li><i>find-max</i> (or <i>find-min</i>): find a maximum item of a max-heap, or a minimum item of a min-heap, respectively (a.k.a. <i><a href="Peek_(data_type_operation)" title="Peek (data type operation)">peek</a></i>)</li>
<li><i>insert</i>: adding a new key to the heap (a.k.a., <i>push</i><sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup>)</li>
<li><i>extract-max</i> (or <i>extract-min</i>): returns the node of maximum value from a max heap [or minimum value from a min heap] after removing it from the heap (a.k.a., <i>pop</i><sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup>)</li>
<li><i>delete-max</i> (or <i>delete-min</i>): removing the root node of a max heap (or min heap), respectively</li>
<li><i>replace</i>: pop root and push a new key. This is more efficient than a pop followed by a push, since it only needs to balance once, not twice, and is appropriate for fixed-size heaps.<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup></li></ul>
<dl><dt>Creation</dt></dl>
<ul><li><i>create-heap</i>: create an empty heap</li>
<li><i>heapify</i>: create a heap out of given array of elements</li>
<li><i>merge</i> (<i>union</i>): joining two heaps to form a valid new heap containing all the elements of both, preserving the original heaps.</li>
<li><i>meld</i>: joining two heaps to form a valid new heap containing all the elements of both, destroying the original heaps.</li></ul>
<dl><dt>Inspection</dt></dl>
<ul><li><i>size</i>: return the number of items in the heap.</li>
<li><i>is-empty</i>: return true if the heap is empty, false otherwise.</li></ul>
<dl><dt>Internal</dt></dl>
<ul><li><i>increase-key</i> or <i>decrease-key</i>: updating a key within a max- or min-heap, respectively</li>
<li><i>delete</i>: delete an arbitrary node (followed by moving last node and sifting to maintain heap)</li>
<li><i>sift-up</i>: move a node up in the tree, as long as needed; used to restore heap condition after insertion. Called "sift" because node moves up the tree until it reaches the correct level, as in a <a href="Sieve" title="Sieve">sieve</a>.</li>
<li><i>sift-down</i>: move a node down in the tree, similar to sift-up; used to restore heap condition after deletion or replacement.</li></ul>
<div class="mw-heading mw-heading2"><h2 id="Implementation_using_arrays">Implementation using arrays</h2></div>
<p>Heaps are usually implemented with an <a href="Array_data_structure" class="mw-redirect" title="Array data structure">array</a>, as follows:
</p>
<ul><li>Each element in the array represents a node of the heap, and</li>
<li>The parent / child relationship is <a href="Implicit_data_structure" title="Implicit data structure">defined implicitly</a> by the elements' indices in the array.</li></ul>
<p>For a <a href="Binary_heap" title="Binary heap">binary heap</a>, in the array, the first index contains the root element. The next two indices of the array contain the root's children. The next four indices contain the four children of the root's two child nodes, and so on. Therefore, given a node at index <span class="texhtml mvar" style="font-style:italic;">i</span>, its children are at indices <span class="nowrap"><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 2i+1}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mn>2</mn>
<mi>i</mi>
<mo>+</mo>
<mn>1</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 2i+1}</annotation>
</semantics>
</math></span><img src="./f077f73c2ecdf3c6e29a120f948a7255c0a65da1.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:5.968ex; height:2.343ex;" alt="{\displaystyle 2i+1}" loading="lazy"></span></span> and <span class="nowrap"><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 2i+2}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mn>2</mn>
<mi>i</mi>
<mo>+</mo>
<mn>2</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 2i+2}</annotation>
</semantics>
</math></span><img src="./a756deaef520ee23fe2b1232c90957f55ec9d92b.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:5.968ex; height:2.343ex;" alt="{\displaystyle 2i+2}" loading="lazy"></span></span>, and its parent is at index <span class="texhtml">⌊(<i>i</i>−1)/2⌋</span>. This simple indexing scheme makes it efficient to move "up" or "down" the tree.
</p><p>Balancing a heap is done by sift-up or sift-down operations (swapping elements which are out of order). As we can build a heap from an array without requiring extra memory (for the nodes, for example), <a href="Heapsort" title="Heapsort">heapsort</a> can be used to sort an array in-place.
</p><p>After an element is inserted into or deleted from a heap, the heap property may be violated, and the heap must be re-balanced by swapping elements within the array.
</p><p>Although different types of heaps implement the operations differently, the most common way is as follows:
</p>
<ul><li><b>Insertion:</b> Add the new element at the end of the heap, in the first available free space. If this will violate the heap property, sift up the new element (<i>swim</i> operation) until the heap property has been reestablished.</li>
<li><b>Extraction:</b> Remove the root and insert the last element of the heap in the root. If this will violate the heap property, sift down the new root (<i>sink</i> operation) to reestablish the heap property.</li>
<li><b>Replacement:</b> Remove the root and put the <i>new</i> element in the root and sift down. When compared to extraction followed by insertion, this avoids a sift up step.</li></ul>
<p>Construction of a binary (or <i>d</i>-ary) heap out of a given array of elements may be performed in linear time using the classic <a href="Heapsort#Variations" title="Heapsort">Floyd algorithm</a>, with the worst-case number of comparisons equal to 2<i>N</i> − 2<i>s</i><sub>2</sub>(<i>N</i>) − <i>e</i><sub>2</sub>(<i>N</i>) (for a binary heap), where <i>s</i><sub>2</sub>(<i>N</i>) is the sum of all digits of the binary representation of <i>N</i> and <i>e</i><sub>2</sub>(<i>N</i>) is the exponent of 2 in the prime factorization of <i>N</i>.<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> This is faster than a sequence of consecutive insertions into an originally empty heap, which is log-linear.<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>a<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Variants">Variants</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1184024115">
/* start https://en.wikipedia.org/ */
.mw-parser-output .div-col{margin-top:0.3em;column-width:30em}.mw-parser-output .div-col-small{font-size:90%}.mw-parser-output .div-col-rules{column-rule:1px solid #aaa}.mw-parser-output .div-col dl,.mw-parser-output .div-col ol,.mw-parser-output .div-col ul{margin-top:0}.mw-parser-output .div-col li,.mw-parser-output .div-col dd{page-break-inside:avoid;break-inside:avoid-column}
/* end https://en.wikipedia.org/ */
</style><div class="div-col" style="column-width: 10em;">
<ul><li><a href="2%E2%80%933_heap" title="2–3 heap">2–3 heap</a></li>
<li><a href="B-heap" title="B-heap">B-heap</a></li>
<li><a href="Beap" title="Beap">Beap</a></li>
<li><a href="Binary_heap" title="Binary heap">Binary heap</a></li>
<li><a href="Binomial_heap" title="Binomial heap">Binomial heap</a></li>
<li><a href="Brodal_queue" title="Brodal queue">Brodal queue</a></li>
<li><a href="D-ary_heap" title="D-ary heap"><i>d</i>-ary heap</a></li>
<li><a href="Fibonacci_heap" title="Fibonacci heap">Fibonacci heap</a></li>
<li><a href="K-D_Heap" class="mw-redirect" title="K-D Heap">K-D Heap</a></li>
<li>Leaf heap</li>
<li><a href="Leftist_tree" title="Leftist tree">Leftist heap</a></li>
<li><a href="Skew_binomial_heap" title="Skew binomial heap">Skew binomial heap</a></li>
<li><a href="Strict_Fibonacci_heap" title="Strict Fibonacci heap">Strict Fibonacci heap</a></li>
<li><a href="Min-max_heap" title="Min-max heap">Min-max heap</a></li>
<li><a href="Pairing_heap" title="Pairing heap">Pairing heap</a></li>
<li><a href="Radix_heap" title="Radix heap">Radix heap</a></li>
<li><a href="Randomized_meldable_heap" title="Randomized meldable heap">Randomized meldable heap</a></li>
<li><a href="Skew_heap" title="Skew heap">Skew heap</a></li>
<li><a href="Soft_heap" title="Soft heap">Soft heap</a></li>
<li><a href="Ternary_heap" class="mw-redirect" title="Ternary heap">Ternary heap</a></li>
<li><a href="Treap" title="Treap">Treap</a></li>
<li><a href="Weak_heap" title="Weak heap">Weak heap</a></li></ul>
</div>
<div class="mw-heading mw-heading2"><h2 id="Comparison_of_theoretic_bounds_for_variants">Comparison of theoretic bounds for variants</h2></div>
<p>Here are <a href="Computational_complexity_theory" title="Computational complexity theory">time complexities</a><sup id="cite_ref-CLRS_9-0" class="reference"><a href="#cite_note-CLRS-9"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup> of various heap data structures. The abbreviation <abbr title="amortized complexity">am.</abbr> indicates that the given complexity is amortized, otherwise it is a worst-case complexity. For the meaning of "<i>O</i>(<i>f</i>)" and "<i>Θ</i>(<i>f</i>)" see <a href="Big_O_notation" title="Big O notation">Big O notation</a>. Names of operations assume a max-heap.
</p>
<table class="wikitable">
<tbody><tr>
<th>Operation
</th>
<th>find-max
</th>
<th>delete-max
</th>
<th>increase-key
</th>
<th>insert
</th>
<th>meld
</th>
<th>make-heap<sup id="cite_ref-13" class="reference"><a href="#cite_note-13"><span class="cite-bracket">[</span>b<span class="cite-bracket">]</span></a></sup>
</th></tr>
<tr>
<th><a href="Binary_heap" title="Binary heap">Binary</a><sup id="cite_ref-CLRS_9-1" class="reference"><a href="#cite_note-CLRS-9"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup>
</th>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ffffdd"><i>Θ</i>(log <i>n</i>)
</td>
<td style="background:#ffffdd"><i>Θ</i>(log <i>n</i>)
</td>
<td style="background:#ffffdd"><i>Θ</i>(log <i>n</i>)
</td>
<td style="background:#ffdddd"><i>Θ</i>(<i>n</i>)
</td>
<td style="background:#ddffdd"><i>Θ</i>(<i>n</i>)
</td></tr>
<tr>
<th><a href="Skew_heap" title="Skew heap">Skew</a><sup id="cite_ref-sleator-tarjan-skew_10-1" class="reference"><a href="#cite_note-sleator-tarjan-skew-10"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup>
</th>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ffffdd"><i>O</i>(log <i>n</i>) <abbr title="amortized complexity">am.</abbr>
</td>
<td style="background:#ffffdd"><i>O</i>(log <i>n</i>) <abbr title="amortized complexity">am.</abbr>
</td>
<td style="background:#ffffdd"><i>O</i>(log <i>n</i>) <abbr title="amortized complexity">am.</abbr>
</td>
<td style="background:#ffffdd"><i>O</i>(log <i>n</i>) <abbr title="amortized complexity">am.</abbr>
</td>
<td style="background:#ddffdd"><i>Θ</i>(<i>n</i>) <abbr title="amortized complexity">am.</abbr>
</td></tr>
<tr>
<th><a href="Leftist_tree" title="Leftist tree">Leftist</a><sup id="cite_ref-tarjan-leftist_11-1" class="reference"><a href="#cite_note-tarjan-leftist-11"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup>
</th>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ffffdd"><i>Θ</i>(log <i>n</i>)
</td>
<td style="background:#ffffdd"><i>Θ</i>(log <i>n</i>)
</td>
<td style="background:#ffffdd"><i>Θ</i>(log <i>n</i>)
</td>
<td style="background:#ffffdd"><i>Θ</i>(log <i>n</i>)
</td>
<td style="background:#ddffdd"><i>Θ</i>(<i>n</i>)
</td></tr>
<tr>
<th><a href="Binomial_heap" title="Binomial heap">Binomial</a><sup id="cite_ref-CLRS_9-2" class="reference"><a href="#cite_note-CLRS-9"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup>
</th>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ffffdd"><i>Θ</i>(log <i>n</i>)
</td>
<td style="background:#ffffdd"><i>Θ</i>(log <i>n</i>)
</td>
<td style="background:#ddffdd"><i>Θ</i>(1) <abbr title="amortized complexity">am.</abbr>
</td>
<td style="background:#ffffdd"><i>Θ</i>(log <i>n</i>)<sup id="cite_ref-bootstrap-meld_15-0" class="reference"><a href="#cite_note-bootstrap-meld-15"><span class="cite-bracket">[</span>c<span class="cite-bracket">]</span></a></sup>
</td>
<td style="background:#ddffdd"><i>Θ</i>(<i>n</i>)
</td></tr>
<tr>
<th><a href="Skew_binomial_heap" title="Skew binomial heap">Skew binomial</a><sup id="cite_ref-brodal-okasaki_16-0" class="reference"><a href="#cite_note-brodal-okasaki-16"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup>
</th>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ffffdd"><i>Θ</i>(log <i>n</i>)
</td>
<td style="background:#ffffdd"><i>Θ</i>(log <i>n</i>)
</td>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ffffdd"><i>Θ</i>(log <i>n</i>)<sup id="cite_ref-bootstrap-meld_15-1" class="reference"><a href="#cite_note-bootstrap-meld-15"><span class="cite-bracket">[</span>c<span class="cite-bracket">]</span></a></sup>
</td>
<td style="background:#ddffdd"><i>Θ</i>(<i>n</i>)
</td></tr>
<tr>
<th><a href="2%E2%80%933_heap" title="2–3 heap">2–3 heap</a><sup id="cite_ref-18" class="reference"><a href="#cite_note-18"><span class="cite-bracket">[</span>15<span class="cite-bracket">]</span></a></sup>
</th>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ffffdd"><i>O</i>(log <i>n</i>) <abbr title="amortized complexity">am.</abbr>
</td>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ddffdd"><i>Θ</i>(1) <abbr title="amortized complexity">am.</abbr>
</td>
<td style="background:#ffffdd"><i>O</i>(log <i>n</i>)<sup id="cite_ref-bootstrap-meld_15-2" class="reference"><a href="#cite_note-bootstrap-meld-15"><span class="cite-bracket">[</span>c<span class="cite-bracket">]</span></a></sup>
</td>
<td style="background:#ddffdd"><i>Θ</i>(<i>n</i>)
</td></tr>
<tr>
<th><a href="Skew_heap" title="Skew heap">Bottom-up skew</a><sup id="cite_ref-sleator-tarjan-skew_10-2" class="reference"><a href="#cite_note-sleator-tarjan-skew-10"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup>
</th>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ffffdd"><i>O</i>(log <i>n</i>) <abbr title="amortized complexity">am.</abbr>
</td>
<td style="background:#ffffdd"><i>O</i>(log <i>n</i>) <abbr title="amortized complexity">am.</abbr>
</td>
<td style="background:#ddffdd"><i>Θ</i>(1) <abbr title="amortized complexity">am.</abbr>
</td>
<td style="background:#ddffdd"><i>Θ</i>(1) <abbr title="amortized complexity">am.</abbr>
</td>
<td style="background:#ddffdd"><i>Θ</i>(<i>n</i>) <abbr title="amortized complexity">am.</abbr>
</td></tr>
<tr>
<th><a href="Pairing_heap" title="Pairing heap">Pairing</a><sup id="cite_ref-Iacono_19-0" class="reference"><a href="#cite_note-Iacono-19"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup>
</th>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ffffdd"><i>O</i>(log <i>n</i>) <abbr title="amortized complexity">am.</abbr>
</td>
<td style="background:#ffffdd"><i>o</i>(log <i>n</i>) <abbr title="amortized complexity">am.</abbr><sup id="cite_ref-pairingdecreasekey_22-0" class="reference"><a href="#cite_note-pairingdecreasekey-22"><span class="cite-bracket">[</span>d<span class="cite-bracket">]</span></a></sup>
</td>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ddffdd"><i>Θ</i>(<i>n</i>)
</td></tr>
<tr>
<th>Rank-pairing<sup id="cite_ref-23" class="reference"><a href="#cite_note-23"><span class="cite-bracket">[</span>19<span class="cite-bracket">]</span></a></sup>
</th>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ffffdd"><i>O</i>(log <i>n</i>) <abbr title="amortized complexity">am.</abbr>
</td>
<td style="background:#ddffdd"><i>Θ</i>(1) <abbr title="amortized complexity">am.</abbr>
</td>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ddffdd"><i>Θ</i>(<i>n</i>)
</td></tr>
<tr>
<th><a href="Fibonacci_heap" title="Fibonacci heap">Fibonacci</a><sup id="cite_ref-CLRS_9-3" class="reference"><a href="#cite_note-CLRS-9"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Fredman_And_Tarjan_24-0" class="reference"><a href="#cite_note-Fredman_And_Tarjan-24"><span class="cite-bracket">[</span>20<span class="cite-bracket">]</span></a></sup>
</th>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ffffdd"><i>O</i>(log <i>n</i>) <abbr title="amortized complexity">am.</abbr>
</td>
<td style="background:#ddffdd"><i>Θ</i>(1) <abbr title="amortized complexity">am.</abbr>
</td>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ddffdd"><i>Θ</i>(<i>n</i>)
</td></tr>
<tr>
<th><a href="Strict_Fibonacci_heap" title="Strict Fibonacci heap">Strict Fibonacci</a><sup id="cite_ref-25" class="reference"><a href="#cite_note-25"><span class="cite-bracket">[</span>21<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-optimum_26-0" class="reference"><a href="#cite_note-optimum-26"><span class="cite-bracket">[</span>e<span class="cite-bracket">]</span></a></sup>
</th>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ffffdd"><i>Θ</i>(log <i>n</i>)
</td>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ddffdd"><i>Θ</i>(<i>n</i>)
</td></tr>
<tr>
<th><a href="Brodal_queue" title="Brodal queue">Brodal</a><sup id="cite_ref-27" class="reference"><a href="#cite_note-27"><span class="cite-bracket">[</span>22<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-optimum_26-1" class="reference"><a href="#cite_note-optimum-26"><span class="cite-bracket">[</span>e<span class="cite-bracket">]</span></a></sup>
</th>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ffffdd"><i>Θ</i>(log <i>n</i>)
</td>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ddffdd"><i>Θ</i>(1)
</td>
<td style="background:#ddffdd"><i>Θ</i>(<i>n</i>)<sup id="cite_ref-28" class="reference"><a href="#cite_note-28"><span class="cite-bracket">[</span>23<span class="cite-bracket">]</span></a></sup>
</td></tr></tbody></table>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */
.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}
/* end https://en.wikipedia.org/ */
</style><div class="reflist reflist-lower-alpha">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text">Each insertion takes O(log(<i>k</i>)) in the existing size of the heap, thus <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \sum _{k=1}^{n}O(\log k)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<munderover>
<mo>∑<!-- ∑ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mi>n</mi>
</mrow>
</munderover>
<mi>O</mi>
<mo stretchy="false">(</mo>
<mi>log</mi>
<mo><!-- --></mo>
<mi>k</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \sum _{k=1}^{n}O(\log k)}</annotation>
</semantics>
</math></span><img src="./57ee533ff7ef5300fd717d9230ca17a135c24df4.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -3.005ex; width:11.895ex; height:6.843ex;" alt="{\displaystyle \sum _{k=1}^{n}O(\log k)}" loading="lazy"></span>. Since <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \log n/2=(\log n)-1}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>log</mi>
<mo><!-- --></mo>
<mi>n</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo>/</mo>
</mrow>
<mn>2</mn>
<mo>=</mo>
<mo stretchy="false">(</mo>
<mi>log</mi>
<mo><!-- --></mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \log n/2=(\log n)-1}</annotation>
</semantics>
</math></span><img src="./4dc03c817e6d65fe0ea9dffce246278943db343e.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:20.743ex; height:2.843ex;" alt="{\displaystyle \log n/2=(\log n)-1}" loading="lazy"></span>, a constant factor (half) of these insertions are within a constant factor of the maximum, so asymptotically we can assume <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle k=n}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>k</mi>
<mo>=</mo>
<mi>n</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle k=n}</annotation>
</semantics>
</math></span><img src="./c4b8cc6fcba0c0b24656b0fb33414d2e6cffb83c.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:5.704ex; height:2.176ex;" alt="{\displaystyle k=n}" loading="lazy"></span>; formally the time is <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle nO(\log n)-O(n)=O(n\log n)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>n</mi>
<mi>O</mi>
<mo stretchy="false">(</mo>
<mi>log</mi>
<mo><!-- --></mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
<mo>−<!-- − --></mo>
<mi>O</mi>
<mo stretchy="false">(</mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mi>O</mi>
<mo stretchy="false">(</mo>
<mi>n</mi>
<mi>log</mi>
<mo><!-- --></mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle nO(\log n)-O(n)=O(n\log n)}</annotation>
</semantics>
</math></span><img src="./d96da998a5bf48e66f5960204a4610d2d9e0a226.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:30.765ex; height:2.843ex;" alt="{\displaystyle nO(\log n)-O(n)=O(n\log n)}" loading="lazy"></span>. This can also be readily seen from <a href="Stirling's_approximation" title="Stirling's approximation">Stirling's approximation</a>.</span>
</li>
<li id="cite_note-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-13">^</a></b></span> <span class="reference-text"><i>make-heap</i> is the operation of building a heap from a sequence of <i>n</i> unsorted elements. It can be done in <i>Θ</i>(<i>n</i>) time whenever <i>meld</i> runs in <i>O</i>(log <i>n</i>) time (where both complexities can be amortized).<sup id="cite_ref-sleator-tarjan-skew_10-0" class="reference"><a href="#cite_note-sleator-tarjan-skew-10"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-tarjan-leftist_11-0" class="reference"><a href="#cite_note-tarjan-leftist-11"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup> Another algorithm achieves <i>Θ</i>(<i>n</i>) for binary heaps.<sup id="cite_ref-hayward-mcdiarmid-heap-build_12-0" class="reference"><a href="#cite_note-hayward-mcdiarmid-heap-build-12"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup></span>
</li>
<li id="cite_note-bootstrap-meld-15"><span class="mw-cite-backlink">^ <a href="#cite_ref-bootstrap-meld_15-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-bootstrap-meld_15-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-bootstrap-meld_15-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text">For <a href="Persistent_data_structure" title="Persistent data structure">persistent</a> heaps (not supporting <i>increase-key</i>), a generic transformation reduces the cost of <i>meld</i> to that of <i>insert</i>, while the new cost of <i>delete-max</i> is the sum of the old costs of <i>delete-max</i> and <i>meld</i>.<sup id="cite_ref-17" class="reference"><a href="#cite_note-17"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup> Here, it makes <i>meld</i> run in <i>Θ</i>(1) time (amortized, if the cost of <i>insert</i> is) while <i>delete-max</i> still runs in <i>O</i>(log <i>n</i>). Applied to skew binomial heaps, it yields Brodal-Okasaki queues, persistent heaps with optimal worst-case complexities.<sup id="cite_ref-brodal-okasaki_16-1" class="reference"><a href="#cite_note-brodal-okasaki-16"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup></span>
</li>
<li id="cite_note-pairingdecreasekey-22"><span class="mw-cite-backlink"><b><a href="#cite_ref-pairingdecreasekey_22-0">^</a></b></span> <span class="reference-text">Lower bound of <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \Omega (\log \log n),}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi mathvariant="normal">Ω<!-- Ω --></mi>
<mo stretchy="false">(</mo>
<mi>log</mi>
<mo><!-- --></mo>
<mi>log</mi>
<mo><!-- --></mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
<mo>,</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \Omega (\log \log n),}</annotation>
</semantics>
</math></span><img src="./7caf8c32fbd99eed1338c02b7f7f1255f16ade36.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:12.247ex; height:2.843ex;" alt="{\displaystyle \Omega (\log \log n),}" loading="lazy"></span><sup id="cite_ref-Fredman1999_20-0" class="reference"><a href="#cite_note-Fredman1999-20"><span class="cite-bracket">[</span>17<span class="cite-bracket">]</span></a></sup> upper bound of <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(2^{2{\sqrt {\log \log n}}}).}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<msup>
<mn>2</mn>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
<mrow class="MJX-TeXAtom-ORD">
<msqrt>
<mi>log</mi>
<mo><!-- --></mo>
<mi>log</mi>
<mo><!-- --></mo>
<mi>n</mi>
</msqrt>
</mrow>
</mrow>
</msup>
<mo stretchy="false">)</mo>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(2^{2{\sqrt {\log \log n}}}).}</annotation>
</semantics>
</math></span><img src="./45c772d2ec070e49a6438ea92b1c8dc764613c5e.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:14.052ex; height:3.509ex;" alt="{\displaystyle O(2^{2{\sqrt {\log \log n}}}).}" loading="lazy"></span><sup id="cite_ref-21" class="reference"><a href="#cite_note-21"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup></span>
</li>
<li id="cite_note-optimum-26"><span class="mw-cite-backlink">^ <a href="#cite_ref-optimum_26-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-optimum_26-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text">Brodal queues and strict Fibonacci heaps achieve optimal worst-case complexities for heaps. They were first described as imperative data structures. The Brodal-Okasaki queue is a <a href="Persistent_data_structure" title="Persistent data structure">persistent</a> data structure achieving the same optimum, except that <i>increase-key</i> is not supported.</span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="Applications">Applications</h2></div>
<p>The heap data structure has many applications.
</p>
<ul><li><a href="Heapsort" title="Heapsort">Heapsort</a>: One of the best sorting methods being in-place and with no quadratic worst-case scenarios.</li>
<li><a href="Selection_algorithm" title="Selection algorithm">Selection algorithms</a>: A heap allows access to the min or max element in constant time, and other selections (such as median or kth-element) can be done in sub-linear time on data that is in a heap.<sup id="cite_ref-29" class="reference"><a href="#cite_note-29"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup></li>
<li><a href="List_of_algorithms#Graph_algorithms" title="List of algorithms">Graph algorithms</a>: By using heaps as internal traversal data structures, run time will be reduced by polynomial order. Examples of such problems are <a href="Prim's_algorithm" title="Prim's algorithm">Prim's minimal-spanning-tree algorithm</a> and <a href="Dijkstra's_algorithm" title="Dijkstra's algorithm">Dijkstra's shortest-path algorithm</a>.</li>
<li><a href="Priority_queue" title="Priority queue">Priority queue</a>: A priority queue is an abstract concept like "a list" or "a map"; just as a list can be implemented with a linked list or an array, a priority queue can be implemented with a heap or a variety of other methods.</li>
<li><a href="K-way_merge_algorithm" title="K-way merge algorithm">K-way merge</a>: A heap data structure is useful to merge many already-sorted input streams into a single sorted output stream. Examples of the need for merging include external sorting and streaming results from distributed data such as a log structured merge tree. The inner loop is obtaining the min element, replacing with the next element for the corresponding input stream, then doing a sift-down heap operation. (Alternatively the replace function.) (Using extract-max and insert functions of a priority queue are much less efficient.)</li></ul>
<div class="mw-heading mw-heading2"><h2 id="Programming_language_implementations">Programming language implementations</h2></div>
<ul><li>The <a href="C%2B%2B_Standard_Library" title="C++ Standard Library">C++ Standard Library</a> provides the <style data-mw-deduplicate="TemplateStyles:r886049734">
/* start https://en.wikipedia.org/ */
.mw-parser-output .monospaced{font-family:monospace,monospace}
/* end https://en.wikipedia.org/ */
</style><span class="monospaced">make_heap</span>, <span class="monospaced">push_heap</span> and <span class="monospaced">pop_heap</span> algorithms for heaps (usually implemented as binary heaps), which operate on arbitrary random access <a href="Iterator" title="Iterator">iterators</a>. It treats the iterators as a reference to an array, and uses the array-to-heap conversion. It also provides the container adaptor <span class="monospaced">priority_queue</span>, which wraps these facilities in a container-like class. However, there is no standard support for the replace, sift-up/sift-down, or decrease/increase-key operations.</li>
<li>The <a href="Boost_(C%2B%2B_libraries)" title="Boost (C++ libraries)">Boost C++ libraries</a> include a heaps library. Unlike the STL, it supports decrease and increase operations, and supports additional types of heap: specifically, it supports <i>d</i>-ary, binomial, Fibonacci, pairing and skew heaps.</li>
<li>There is a <a rel="nofollow" class="external text" href="https://github.com/valyala/gheap">generic heap implementation</a> for <a href="C_(programming_language)" title="C (programming language)">C</a> and <a href="C%2B%2B" title="C++">C++</a> with <a href="D-ary_heap" title="D-ary heap">D-ary heap</a> and <a href="B-heap" title="B-heap">B-heap</a> support. It provides an STL-like API.</li>
<li>The standard library of the <a href="D_(programming_language)" title="D (programming language)">D programming language</a> includes <a rel="nofollow" class="external text" href="https://dlang.org/phobos/std_container_binaryheap.html"><span class="monospaced">std.container.BinaryHeap</span></a>, which is implemented in terms of D's <a rel="nofollow" class="external text" href="https://tour.dlang.org/tour/en/basics/ranges">ranges</a>. Instances can be constructed from any <a rel="nofollow" class="external text" href="https://dlang.org/phobos/std_range_primitives.html#isRandomAccessRange">random-access range</a>. <span class="monospaced">BinaryHeap</span> exposes an <a rel="nofollow" class="external text" href="https://dlang.org/phobos/std_range_primitives.html#isInputRange">input range interface</a> that allows iteration with D's built-in <span class="monospaced">foreach</span> statements and integration with the range-based API of the <a rel="nofollow" class="external text" href="https://dlang.org/phobos/std_algorithm.html"><span class="monospaced">std.algorithm</span> package</a>.</li>
<li>For <a href="Haskell" title="Haskell">Haskell</a> there is the <a rel="nofollow" class="external text" href="https://hackage.haskell.org/package/heaps"><span class="monospaced">Data.Heap</span></a> module.</li>
<li>The <a href="Java_(programming_language)" title="Java (programming language)">Java</a> platform (since version 1.5) provides a binary heap implementation with the class <code><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/util/PriorityQueue.html">java.util.PriorityQueue</a></code> in the <a href="Java_Collections_Framework" class="mw-redirect" title="Java Collections Framework">Java Collections Framework</a>. This class implements by default a min-heap; to implement a max-heap, programmer should write a custom comparator. There is no support for the replace, sift-up/sift-down, or decrease/increase-key operations.</li>
<li><a href="Python_(programming_language)" title="Python (programming language)">Python</a> has a <a rel="nofollow" class="external text" href="https://docs.python.org/library/heapq.html"><span class="monospaced">heapq</span></a> module that implements a priority queue using a binary heap. The library exposes a heapreplace function to support k-way merging. Python only supports a min-heap implementation.</li>
<li><a href="PHP" title="PHP">PHP</a> has both max-heap (<span class="monospaced">SplMaxHeap</span>) and min-heap (<span class="monospaced">SplMinHeap</span>) as of version 5.3 in the Standard PHP Library.</li>
<li><a href="Perl" title="Perl">Perl</a> has implementations of binary, binomial, and Fibonacci heaps in the <a rel="nofollow" class="external text" href="https://metacpan.org/module/Heap"><span class="monospaced">Heap</span></a> distribution available on <a href="CPAN" title="CPAN">CPAN</a>.</li>
<li>The <a href="Go_(programming_language)" title="Go (programming language)">Go</a> language contains a <a rel="nofollow" class="external text" href="https://golang.org/pkg/container/heap/"><span class="monospaced">heap</span></a> package with heap algorithms that operate on an arbitrary type that satisfies a given interface. That package does not support the replace, sift-up/sift-down, or decrease/increase-key operations.</li>
<li>Apple's <a href="Core_Foundation" title="Core Foundation">Core Foundation</a> library contains a <a rel="nofollow" class="external text" href="https://developer.apple.com/documentation/corefoundation/cfbinaryheap"><span class="monospaced">CFBinaryHeap</span></a> structure.</li>
<li><a href="Pharo" title="Pharo">Pharo</a> has an implementation of a heap in the Collections-Sequenceable package along with a set of test cases. A heap is used in the implementation of the timer event loop.</li>
<li>The <a href="Rust_(programming_language)" title="Rust (programming language)">Rust</a> programming language has a binary max-heap implementation, <a rel="nofollow" class="external text" href="https://doc.rust-lang.org/std/collections/struct.BinaryHeap.html"><span class="monospaced">BinaryHeap</span></a>, in the <span class="monospaced">collections</span> module of its standard library.</li>
<li><a href=".NET" title=".NET">.NET</a> has <a rel="nofollow" class="external text" href="https://docs.microsoft.com/dotnet/api/system.collections.generic.priorityqueue-2">PriorityQueue</a> class which uses quaternary (d-ary) min-heap implementation. It is available from .NET 6.</li></ul>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Sorting_algorithm" title="Sorting algorithm">Sorting algorithm</a></li>
<li><a href="Search_data_structure" title="Search data structure">Search data structure</a></li>
<li><a href="Treap" title="Treap">Treap</a>, a form of binary search tree based on heap-ordered trees</li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<div class="reflist">
<div class="mw-references-wrap mw-references-columns"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text">Black (ed.), Paul E. (2004-12-14). Entry for <i>heap</i> in <i><a href="Dictionary_of_Algorithms_and_Data_Structures" class="mw-redirect" title="Dictionary of Algorithms and Data Structures">Dictionary of Algorithms and Data Structures</a></i>. Online version. U.S. <a href="National_Institute_of_Standards_and_Technology" title="National Institute of Standards and Technology">National Institute of Standards and Technology</a>, 14 December 2004. Retrieved on 2017-10-08 from <a rel="nofollow" class="external free" href="https://xlinux.nist.gov/dads/HTML/heap.html">https://xlinux.nist.gov/dads/HTML/heap.html</a>.</span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */
.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}
/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFCORMEN2009" class="citation book cs1">CORMEN, THOMAS H. (2009). <i>INTRODUCTION TO ALGORITHMS</i>. United States of America: The MIT Press Cambridge, Massachusetts London, England. pp. <span class="nowrap">151–</span>152. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-262-03384-8</bdi>.</cite></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><cite id="CITEREFWilliams1964" class="citation cs2"><a href="J._W._J._Williams" title="J. W. J. Williams">Williams, J. W. J.</a> (1964), "Algorithm 232 - Heapsort", <i><a href="Communications_of_the_ACM" title="Communications of the ACM">Communications of the ACM</a></i>, <b>7</b> (6): <span class="nowrap">347–</span>348, <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F512274.512284">10.1145/512274.512284</a></cite></span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text">The Python Standard Library, 8.4. heapq — Heap queue algorithm, <a rel="nofollow" class="external text" href="https://docs.python.org/3/library/heapq.html#heapq.heappush">heapq.heappush</a></span>
</li>
<li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text">The Python Standard Library, 8.4. heapq — Heap queue algorithm, <a rel="nofollow" class="external text" href="https://docs.python.org/3/library/heapq.html#heapq.heappop">heapq.heappop</a></span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text">The Python Standard Library, 8.4. heapq — Heap queue algorithm, <a rel="nofollow" class="external text" href="https://docs.python.org/3/library/heapq.html#heapq.heapreplace">heapq.heapreplace</a></span>
</li>
<li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><cite id="CITEREFSuchenek2012" class="citation cs2">Suchenek, Marek A. (2012), "Elementary Yet Precise Worst-Case Analysis of Floyd's Heap-Construction Program", <i>Fundamenta Informaticae</i>, <b>120</b> (1), IOS Press: <span class="nowrap">75–</span>92, <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.3233%2FFI-2012-751">10.3233/FI-2012-751</a></cite>.</span>
</li>
<li id="cite_note-CLRS-9"><span class="mw-cite-backlink">^ <a href="#cite_ref-CLRS_9-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-CLRS_9-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-CLRS_9-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-CLRS_9-3"><sup><i><b>d</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFCormenLeisersonRivest1990" class="citation book cs1"><a href="Thomas_H._Cormen" title="Thomas H. Cormen">Cormen, Thomas H.</a>; <a href="Charles_E._Leiserson" title="Charles E. Leiserson">Leiserson, Charles E.</a>; <a href="Ron_Rivest" title="Ron Rivest">Rivest, Ronald L.</a> (1990). <a href="Introduction_to_Algorithms" title="Introduction to Algorithms"><i>Introduction to Algorithms</i></a> (1st ed.). MIT Press and McGraw-Hill. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>0-262-03141-8</bdi>.</cite></span>
</li>
<li id="cite_note-sleator-tarjan-skew-10"><span class="mw-cite-backlink">^ <a href="#cite_ref-sleator-tarjan-skew_10-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-sleator-tarjan-skew_10-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-sleator-tarjan-skew_10-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFSleatorTarjan1986" class="citation journal cs1"><a href="Daniel_Sleator" title="Daniel Sleator">Sleator, Daniel Dominic</a>; <a href="Robert_Tarjan" title="Robert Tarjan">Tarjan, Robert Endre</a> (February 1986). <a rel="nofollow" class="external text" href="https://www.cs.cmu.edu/~sleator/papers/Adjusting-Heaps.htm">"Self-Adjusting Heaps"</a>. <i><a href="SIAM_Journal_on_Computing" title="SIAM Journal on Computing">SIAM Journal on Computing</a></i>. <b>15</b> (1): <span class="nowrap">52–</span>69. <a href="CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a> <span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.93.6678">10.1.1.93.6678</a></span>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1137%2F0215004">10.1137/0215004</a>. <a href="ISSN_(identifier)" class="mw-redirect" title="ISSN (identifier)">ISSN</a> <a rel="nofollow" class="external text" href="https://search.worldcat.org/issn/0097-5397">0097-5397</a>.</cite></span>
</li>
<li id="cite_note-tarjan-leftist-11"><span class="mw-cite-backlink">^ <a href="#cite_ref-tarjan-leftist_11-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-tarjan-leftist_11-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFTarjan1983" class="citation book cs1"><a href="Robert_Tarjan" title="Robert Tarjan">Tarjan, Robert</a> (1983). "3.3. Leftist heaps". <i>Data Structures and Network Algorithms</i>. pp. <span class="nowrap">38–</span>42. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1137%2F1.9781611970265">10.1137/1.9781611970265</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-89871-187-5</bdi>.</cite></span>
</li>
<li id="cite_note-hayward-mcdiarmid-heap-build-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-hayward-mcdiarmid-heap-build_12-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFHaywardMcDiarmid1991" class="citation journal cs1">Hayward, Ryan; McDiarmid, Colin (1991). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20160205023201/http://www.stats.ox.ac.uk/__data/assets/pdf_file/0015/4173/heapbuildjalg.pdf">"Average Case Analysis of Heap Building by Repeated Insertion"</a> <span class="cs1-format">(PDF)</span>. <i>J. Algorithms</i>. <b>12</b>: <span class="nowrap">126–</span>153. <a href="CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a> <span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.353.7888">10.1.1.353.7888</a></span>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1016%2F0196-6774%2891%2990027-v">10.1016/0196-6774(91)90027-v</a>. Archived from <a rel="nofollow" class="external text" href="http://www.stats.ox.ac.uk/__data/assets/pdf_file/0015/4173/heapbuildjalg.pdf">the original</a> <span class="cs1-format">(PDF)</span> on 2016-02-05<span class="reference-accessdate">. Retrieved <span class="nowrap">2016-01-28</span></span>.</cite></span>
</li>
<li id="cite_note-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-14">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://brilliant.org/wiki/binomial-heap/">"Binomial Heap | Brilliant Math & Science Wiki"</a>. <i>brilliant.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2019-09-30</span></span>.</cite></span>
</li>
<li id="cite_note-brodal-okasaki-16"><span class="mw-cite-backlink">^ <a href="#cite_ref-brodal-okasaki_16-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-brodal-okasaki_16-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFBrodalOkasaki1996" class="citation cs2">Brodal, Gerth Stølting; Okasaki, Chris (November 1996), "Optimal purely functional priority queues", <i>Journal of Functional Programming</i>, <b>6</b> (6): <span class="nowrap">839–</span>857, <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1017%2Fs095679680000201x">10.1017/s095679680000201x</a></span></cite></span>
</li>
<li id="cite_note-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-17">^</a></b></span> <span class="reference-text"><cite id="CITEREFOkasaki1998" class="citation book cs1"><a href="Chris_Okasaki" title="Chris Okasaki">Okasaki, Chris</a> (1998). "10.2. Structural Abstraction". <i>Purely Functional Data Structures</i> (1st ed.). pp. <span class="nowrap">158–</span>162. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>9780521631242</bdi>.</cite></span>
</li>
<li id="cite_note-18"><span class="mw-cite-backlink"><b><a href="#cite_ref-18">^</a></b></span> <span class="reference-text"><cite id="CITEREFTakaoka1999" class="citation cs2">Takaoka, Tadao (1999), <a rel="nofollow" class="external text" href="https://ir.canterbury.ac.nz/bitstream/handle/10092/14769/2-3heaps.pdf"><i>Theory of 2–3 Heaps</i></a> <span class="cs1-format">(PDF)</span>, p. 12</cite></span>
</li>
<li id="cite_note-Iacono-19"><span class="mw-cite-backlink"><b><a href="#cite_ref-Iacono_19-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFIacono2000" class="citation cs2"><a href="John_Iacono" title="John Iacono">Iacono, John</a> (2000), "Improved upper bounds for pairing heaps", <a rel="nofollow" class="external text" href="http://john2.poly.edu/papers/swat00/paper.pdf"><i>Proc. 7th Scandinavian Workshop on Algorithm Theory</i></a> <span class="cs1-format">(PDF)</span>, Lecture Notes in Computer Science, vol. 1851, Springer-Verlag, pp. <span class="nowrap">63–</span>77, <a href="ArXiv_(identifier)" class="mw-redirect" title="ArXiv (identifier)">arXiv</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/1110.4428">1110.4428</a></span>, <a href="CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a> <span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.748.7812">10.1.1.748.7812</a></span>, <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1007%2F3-540-44985-X_5">10.1007/3-540-44985-X_5</a>, <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>3-540-67690-2</bdi></cite></span>
</li>
<li id="cite_note-Fredman1999-20"><span class="mw-cite-backlink"><b><a href="#cite_ref-Fredman1999_20-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFFredman1999" class="citation journal cs1"><a href="Michael_Fredman" title="Michael Fredman">Fredman, Michael Lawrence</a> (July 1999). <a rel="nofollow" class="external text" href="http://www.uqac.ca/azinflou/Fichiers840/EfficiencyPairingHeap.pdf">"On the Efficiency of Pairing Heaps and Related Data Structures"</a> <span class="cs1-format">(PDF)</span>. <i><a href="Journal_of_the_Association_for_Computing_Machinery" class="mw-redirect" title="Journal of the Association for Computing Machinery">Journal of the Association for Computing Machinery</a></i>. <b>46</b> (4): <span class="nowrap">473–</span>501. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F320211.320214">10.1145/320211.320214</a>.</cite></span>
</li>
<li id="cite_note-21"><span class="mw-cite-backlink"><b><a href="#cite_ref-21">^</a></b></span> <span class="reference-text"><cite id="CITEREFPettie2005" class="citation conference cs1">Pettie, Seth (2005). <a rel="nofollow" class="external text" href="http://web.eecs.umich.edu/~pettie/papers/focs05.pdf"><i>Towards a Final Analysis of Pairing Heaps</i></a> <span class="cs1-format">(PDF)</span>. FOCS '05 Proceedings of the 46th Annual IEEE Symposium on Foundations of Computer Science. pp. <span class="nowrap">174–</span>183. <a href="CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a> <span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.549.471">10.1.1.549.471</a></span>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1109%2FSFCS.2005.75">10.1109/SFCS.2005.75</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>0-7695-2468-0</bdi>.</cite></span>
</li>
<li id="cite_note-23"><span class="mw-cite-backlink"><b><a href="#cite_ref-23">^</a></b></span> <span class="reference-text"><cite id="CITEREFHaeuplerSenTarjan2011" class="citation journal cs1">Haeupler, Bernhard; Sen, Siddhartha; <a href="Robert_Tarjan" title="Robert Tarjan">Tarjan, Robert E.</a> (November 2011). <a rel="nofollow" class="external text" href="http://sidsen.org/papers/rp-heaps-journal.pdf">"Rank-pairing heaps"</a> <span class="cs1-format">(PDF)</span>. <i>SIAM J. Computing</i>. <b>40</b> (6): <span class="nowrap">1463–</span>1485. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1137%2F100785351">10.1137/100785351</a>.</cite></span>
</li>
<li id="cite_note-Fredman_And_Tarjan-24"><span class="mw-cite-backlink"><b><a href="#cite_ref-Fredman_And_Tarjan_24-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFFredmanTarjan1987" class="citation journal cs1"><a href="Michael_Fredman" title="Michael Fredman">Fredman, Michael Lawrence</a>; <a href="Robert_Tarjan" title="Robert Tarjan">Tarjan, Robert E.</a> (July 1987). <a rel="nofollow" class="external text" href="http://bioinfo.ict.ac.cn/~dbu/AlgorithmCourses/Lectures/Fibonacci-Heap-Tarjan.pdf">"Fibonacci heaps and their uses in improved network optimization algorithms"</a> <span class="cs1-format">(PDF)</span>. <i><a href="Journal_of_the_Association_for_Computing_Machinery" class="mw-redirect" title="Journal of the Association for Computing Machinery">Journal of the Association for Computing Machinery</a></i>. <b>34</b> (3): <span class="nowrap">596–</span>615. <a href="CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a> <span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.309.8927">10.1.1.309.8927</a></span>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F28869.28874">10.1145/28869.28874</a>.</cite></span>
</li>
<li id="cite_note-25"><span class="mw-cite-backlink"><b><a href="#cite_ref-25">^</a></b></span> <span class="reference-text"><cite id="CITEREFBrodalLagogiannisTarjan2012" class="citation conference cs1"><a href="Gerth_St%C3%B8lting_Brodal" class="mw-redirect" title="Gerth Stølting Brodal">Brodal, Gerth Stølting</a>; Lagogiannis, George; <a href="Robert_Tarjan" title="Robert Tarjan">Tarjan, Robert E.</a> (2012). <a rel="nofollow" class="external text" href="http://www.cs.au.dk/~gerth/papers/stoc12.pdf"><i>Strict Fibonacci heaps</i></a> <span class="cs1-format">(PDF)</span>. Proceedings of the 44th symposium on Theory of Computing - STOC '12. pp. <span class="nowrap">1177–</span>1184. <a href="CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a> <span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.233.1740">10.1.1.233.1740</a></span>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F2213977.2214082">10.1145/2213977.2214082</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-1-4503-1245-5</bdi>.</cite></span>
</li>
<li id="cite_note-27"><span class="mw-cite-backlink"><b><a href="#cite_ref-27">^</a></b></span> <span class="reference-text"><cite id="CITEREFBrodal1996" class="citation cs2"><a href="Gerth_St%C3%B8lting_Brodal" class="mw-redirect" title="Gerth Stølting Brodal">Brodal, Gerth S.</a> (1996), <a rel="nofollow" class="external text" href="http://www.cs.au.dk/~gerth/papers/soda96.pdf">"Worst-Case Efficient Priority Queues"</a> <span class="cs1-format">(PDF)</span>, <i>Proc. 7th Annual ACM-SIAM Symposium on Discrete Algorithms</i>, pp. <span class="nowrap">52–</span>58</cite></span>
</li>
<li id="cite_note-28"><span class="mw-cite-backlink"><b><a href="#cite_ref-28">^</a></b></span> <span class="reference-text"><cite id="CITEREFGoodrichTamassia2004" class="citation book cs1"><a href="Michael_T._Goodrich" title="Michael T. Goodrich">Goodrich, Michael T.</a>; <a href="Roberto_Tamassia" title="Roberto Tamassia">Tamassia, Roberto</a> (2004). "7.3.6. Bottom-Up Heap Construction". <i>Data Structures and Algorithms in Java</i> (3rd ed.). pp. <span class="nowrap">338–</span>341. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>0-471-46983-1</bdi>.</cite></span>
</li>
<li id="cite_note-29"><span class="mw-cite-backlink"><b><a href="#cite_ref-29">^</a></b></span> <span class="reference-text"><cite id="CITEREFFrederickson1993" class="citation cs2">Frederickson, Greg N. (1993), "An Optimal Algorithm for Selection in a Min-Heap", <a rel="nofollow" class="external text" href="https://web.archive.org/web/20121203045606/http://ftp.cs.purdue.edu/research/technical_reports/1991/TR%2091-027.pdf"><i>Information and Computation</i></a> <span class="cs1-format">(PDF)</span>, vol. 104, Academic Press, pp. <span class="nowrap">197–</span>214, <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1006%2Finco.1993.1030">10.1006/inco.1993.1030</a></span>, archived from <a rel="nofollow" class="external text" href="http://ftp.cs.purdue.edu/research/technical_reports/1991/TR%2091-027.pdf">the original</a> <span class="cs1-format">(PDF)</span> on 2012-12-03<span class="reference-accessdate">, retrieved <span class="nowrap">2010-10-31</span></span></cite></span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1290876196">
/* start https://en.wikipedia.org/ */
.mw-parser-output .side-box{margin:4px 0;box-sizing:border-box;border:1px solid #aaa;font-size:88%;line-height:1.25em;background-color:var(--background-color-interactive-subtle,#f8f9fa);display:flow-root}.mw-parser-output .infobox .side-box{font-size:100%}.mw-parser-output .side-box-abovebelow,.mw-parser-output .side-box-text{padding:0.25em 0.9em}.mw-parser-output .side-box-image{padding:2px 0 2px 0.9em;text-align:center}.mw-parser-output .side-box-imageright{padding:2px 0.9em 2px 0;text-align:center}@media(min-width:500px){.mw-parser-output .side-box-flex{display:flex;align-items:center}.mw-parser-output .side-box-text{flex:1;min-width:0}}@media(min-width:720px){.mw-parser-output .side-box{width:238px}.mw-parser-output .side-box-right{clear:right;float:right;margin-left:1em}.mw-parser-output .side-box-left{margin-right:1em}}
/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1237033735">
/* start https://en.wikipedia.org/ */
@media print{body.ns-0 .mw-parser-output .sistersitebox{display:none!important}}@media screen{html.skin-theme-clientpref-night .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}
/* end https://en.wikipedia.org/ */
</style><div class="side-box side-box-right sistersitebox"><style data-mw-deduplicate="TemplateStyles:r1126788409">
/* start https://en.wikipedia.org/ */
.mw-parser-output .plainlist ol,.mw-parser-output .plainlist ul{line-height:inherit;list-style:none;margin:0;padding:0}.mw-parser-output .plainlist ol li,.mw-parser-output .plainlist ul li{margin-bottom:0}
/* end https://en.wikipedia.org/ */
</style>
<div class="side-box-flex">
<div class="side-box-image"><span class="noviewer" typeof="mw:File"></span></div>
<div class="side-box-text plainlist">Wikimedia Commons has media related to <span style="font-weight: bold; font-style: italic;"><a href="https://commons.wikimedia.org/wiki/Category:Heap_data_structures" class="extiw external" title="commons:Category:Heap data structures">Heap data structures</a></span>.</div></div>
</div>
<div class="side-box side-box-right sistersitebox">
<div class="side-box-flex">
<div class="side-box-image"><span class="noviewer" typeof="mw:File"></span></div>
<div class="side-box-text plainlist">The Wikibook <i><a href="https://en.wikibooks.org/wiki/Data_Structures" class="extiw external" title="wikibooks:Data Structures">Data Structures</a></i> has a page on the topic of: <i><b><a href="https://en.wikibooks.org/wiki/Data_Structures/Min_and_Max_Heaps" class="extiw external" title="wikibooks:Data Structures/Min and Max Heaps">Min and Max Heaps</a></b></i></div></div>
</div>
<ul><li><a rel="nofollow" class="external text" href="http://mathworld.wolfram.com/Heap.html">Heap</a> at Wolfram MathWorld</li>
<li><a rel="nofollow" class="external text" href="https://www.cs.auckland.ac.nz/software/AlgAnim/heaps.html">Explanation</a> of how the basic heap algorithms work</li>
<li><cite id="CITEREFBentley2000" class="citation book cs1">Bentley, Jon Louis (2000). <i>Programming Pearls</i> (2nd ed.). Addison Wesley. pp. <span class="nowrap">147–</span>162. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>0201657880</bdi>.</cite></li></ul>
<div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}
/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1236075235">
/* start https://en.wikipedia.org/ */
.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}
/* end https://en.wikipedia.org/ */
</style></div><div role="navigation" class="navbox" aria-labelledby="Tree_data_structures246" style="padding:3px"><table class="nowraplinks mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><style data-mw-deduplicate="TemplateStyles:r1239400231">
/* start https://en.wikipedia.org/ */
.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><div id="Tree_data_structures246" style="font-size:114%;margin:0 4em"><a href="Tree_(abstract_data_type)" title="Tree (abstract data type)">Tree data structures</a></div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Search_tree" title="Search tree">Search trees</a><br>(<a href="Set_(abstract_data_type)" title="Set (abstract data type)">dynamic sets</a>,<br><a href="Associative_array" title="Associative array">associative arrays</a>)</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="2%E2%80%933_tree" title="2–3 tree">2–3</a></li>
<li><a href="2%E2%80%933%E2%80%934_tree" title="2–3–4 tree">2–3–4</a></li>
<li><a href="AA_tree" title="AA tree">AA</a></li>
<li><a href="(a%2Cb)-tree" class="mw-redirect" title="(a,b)-tree">(a,b)</a></li>
<li><a href="AVL_tree" title="AVL tree">AVL</a></li>
<li><a href="B-tree" title="B-tree">B</a>
<ul><li><a href="K-D-B-tree" title="K-D-B-tree">K-Dimensional</a></li></ul></li>
<li><a href="B%2B_tree" title="B+ tree">B+</a></li>
<li><a href="B*-tree" class="mw-redirect" title="B*-tree">B*</a></li>
<li><a href="Bx-tree" title="Bx-tree">B<sup>x</sup></a></li>
<li><a href="Binary_search_tree" title="Binary search tree">Binary search</a>
<ul><li><a href="Optimal_binary_search_tree" title="Optimal binary search tree">Optimal</a></li>
<li><a href="Self-balancing_binary_search_tree" title="Self-balancing binary search tree">Self-balancing</a></li></ul></li>
<li><a href="Dancing_tree" title="Dancing tree">Dancing</a></li>
<li><a href="HTree" title="HTree">HTree</a></li>
<li><a href="Interval_tree" title="Interval tree">Interval</a></li>
<li><a href="Order_statistic_tree" title="Order statistic tree">Order statistic</a></li>
<li><a href="Palindrome_tree" title="Palindrome tree">Palindrome</a></li>
<li>(<a href="Left-leaning_red%E2%80%93black_tree" title="Left-leaning red–black tree">Left-leaning</a>) <a href="Red%E2%80%93black_tree" title="Red–black tree">Red–black</a></li>
<li><a href="Scapegoat_tree" title="Scapegoat tree">Scapegoat</a></li>
<li><a href="Splay_tree" title="Splay tree">Splay</a></li>
<li><a href="T-tree" title="T-tree">T</a></li>
<li><a href="Treap" title="Treap">Treap</a></li>
<li><a href="UB-tree" title="UB-tree">UB</a></li>
<li><a href="Weight-balanced_tree" title="Weight-balanced tree">Weight-balanced</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Binary_heap" title="Binary heap">Binary</a></li>
<li><a href="Binomial_heap" title="Binomial heap">Binomial</a></li>
<li><a href="Brodal_queue" title="Brodal queue">Brodal</a></li>
<li><a href="D-ary_heap" title="D-ary heap"><i>d</i>-ary</a></li>
<li><a href="Fibonacci_heap" title="Fibonacci heap">Fibonacci</a></li>
<li><a href="Leftist_tree" title="Leftist tree">Leftist</a></li>
<li><a href="Pairing_heap" title="Pairing heap">Pairing</a></li>
<li><a href="Skew_binomial_heap" title="Skew binomial heap">Skew binomial</a></li>
<li><a href="Skew_heap" title="Skew heap">Skew</a></li>
<li><a href="Van_Emde_Boas_tree" title="Van Emde Boas tree">van Emde Boas</a></li>
<li><a href="Weak_heap" title="Weak heap">Weak</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Trie" title="Trie">Tries</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Ctrie" title="Ctrie">Ctrie</a></li>
<li><a href="C-trie" title="C-trie">C-trie</a> (compressed ADT)</li>
<li><a href="Hash_tree_(persistent_data_structure)" title="Hash tree (persistent data structure)">Hash</a></li>
<li><a href="Radix_tree" title="Radix tree">Radix</a></li>
<li><a href="Suffix_tree" title="Suffix tree">Suffix</a></li>
<li><a href="Ternary_search_tree" title="Ternary search tree">Ternary search</a></li>
<li><a href="X-fast_trie" title="X-fast trie">X-fast</a></li>
<li><a href="Y-fast_trie" title="Y-fast trie">Y-fast</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Spatial_index" class="mw-redirect" title="Spatial index">Spatial</a> data<br>partitioning trees</th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Ball_tree" title="Ball tree">Ball</a></li>
<li><a href="BK-tree" title="BK-tree">BK</a></li>
<li><a href="BSP_tree" class="mw-redirect" title="BSP tree">BSP</a></li>
<li><a href="Cartesian_tree" title="Cartesian tree">Cartesian</a></li>
<li><a href="Hilbert_R-tree" title="Hilbert R-tree">Hilbert R</a></li>
<li><a href="K-d_tree" title="K-d tree"><i>k</i>-d</a> (<a href="Implicit_k-d_tree" title="Implicit k-d tree">implicit <i>k</i>-d</a>)</li>
<li><a href="M-tree" title="M-tree">M</a></li>
<li><a href="Metric_tree" title="Metric tree">Metric</a></li>
<li><a href="MVP_tree" class="mw-redirect" title="MVP tree">MVP</a></li>
<li><a href="Octree" title="Octree">Octree</a></li>
<li><a href="PH-tree" title="PH-tree">PH</a></li>
<li><a href="Priority_R-tree" title="Priority R-tree">Priority R</a></li>
<li><a href="Quadtree" title="Quadtree">Quad</a></li>
<li><a href="R-tree" title="R-tree">R</a></li>
<li><a href="R%2B_tree" title="R+ tree">R+</a></li>
<li><a href="R*_tree" class="mw-redirect" title="R* tree">R*</a></li>
<li><a href="Segment_tree" title="Segment tree">Segment</a></li>
<li><a href="Vantage-point_tree" title="Vantage-point tree">VP</a></li>
<li><a href="X-tree" title="X-tree">X</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Other trees</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Cover_tree" title="Cover tree">Cover</a></li>
<li><a href="Exponential_tree" title="Exponential tree">Exponential</a></li>
<li><a href="Fenwick_tree" title="Fenwick tree">Fenwick</a></li>
<li><a href="Finger_tree" title="Finger tree">Finger</a></li>
<li><a href="Fractal_tree_index" title="Fractal tree index">Fractal index</a></li>
<li><a href="Fusion_tree" title="Fusion tree">Fusion</a></li>
<li><a href="Hash_calendar" title="Hash calendar">Hash calendar</a></li>
<li><a href="IDistance" title="IDistance">iDistance</a></li>
<li><a href="K-ary_tree" class="mw-redirect" title="K-ary tree">K-ary</a></li>
<li><a href="Left-child_right-sibling_binary_tree" title="Left-child right-sibling binary tree">Left-child right-sibling</a></li>
<li><a href="Link/cut_tree" title="Link/cut tree">Link/cut</a></li>
<li><a href="Log-structured_merge-tree" title="Log-structured merge-tree">Log-structured merge</a></li>
<li><a href="Merkle_tree" title="Merkle tree">Merkle</a></li>
<li><a href="PQ_tree" title="PQ tree">PQ</a></li>
<li><a href="Range_tree" title="Range tree">Range</a></li>
<li><a href="SPQR_tree" title="SPQR tree">SPQR</a></li>
<li><a href="Top_tree" title="Top tree">Top</a></li></ul>
</div></td></tr></tbody></table></div>
<div class="navbox-styles"></div><div role="navigation" class="navbox" aria-labelledby="Data_structures216" style="padding:3px"><table class="nowraplinks hlist mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><div id="Data_structures216" style="font-size:114%;margin:0 4em"><a href="Data_structure" title="Data structure">Data structures</a></div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%">Types</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Collection_(abstract_data_type)" title="Collection (abstract data type)">Collection</a></li>
<li><a href="Container_(abstract_data_type)" title="Container (abstract data type)">Container</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Abstract_data_type" title="Abstract data type">Abstract</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Associative_array" title="Associative array">Associative array</a>
<ul><li><a href="Multimap" title="Multimap">Multimap</a></li>
<li><a href="Retrieval_Data_Structure" title="Retrieval Data Structure">Retrieval Data Structure</a></li></ul></li>
<li><a href="List_(abstract_data_type)" title="List (abstract data type)">List</a></li>
<li><a href="Stack_(abstract_data_type)" title="Stack (abstract data type)">Stack</a></li>
<li><a href="Queue_(abstract_data_type)" title="Queue (abstract data type)">Queue</a>
<ul><li><a href="Double-ended_queue" title="Double-ended queue">Double-ended queue</a></li></ul></li>
<li><a href="Priority_queue" title="Priority queue">Priority queue</a>
<ul><li><a href="Double-ended_priority_queue" title="Double-ended priority queue">Double-ended priority queue</a></li></ul></li>
<li><a href="Set_(abstract_data_type)" title="Set (abstract data type)">Set</a>
<ul><li><a href="Set_(abstract_data_type)#Multiset" title="Set (abstract data type)">Multiset</a></li>
<li><a href="Disjoint-set_data_structure" title="Disjoint-set data structure">Disjoint-set</a></li></ul></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Array_(data_structure)" title="Array (data structure)">Arrays</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Bit_array" title="Bit array">Bit array</a></li>
<li><a href="Circular_buffer" title="Circular buffer">Circular buffer</a></li>
<li><a href="Dynamic_array" title="Dynamic array">Dynamic array</a></li>
<li><a href="Hash_table" title="Hash table">Hash table</a></li>
<li><a href="Hashed_array_tree" title="Hashed array tree">Hashed array tree</a></li>
<li><a href="Sparse_matrix" title="Sparse matrix">Sparse matrix</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Linked_data_structure" title="Linked data structure">Linked</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Association_list" title="Association list">Association list</a></li>
<li><a href="Linked_list" title="Linked list">Linked list</a></li>
<li><a href="Skip_list" title="Skip list">Skip list</a></li>
<li><a href="Unrolled_linked_list" title="Unrolled linked list">Unrolled linked list</a></li>
<li><a href="XOR_linked_list" title="XOR linked list">XOR linked list</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Tree_(data_structure)" class="mw-redirect" title="Tree (data structure)">Trees</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="B-tree" title="B-tree">B-tree</a></li>
<li><a href="Binary_search_tree" title="Binary search tree">Binary search tree</a>
<ul><li><a href="AA_tree" title="AA tree">AA tree</a></li>
<li><a href="AVL_tree" title="AVL tree">AVL tree</a></li>
<li><a href="Red%E2%80%93black_tree" title="Red–black tree">Red–black tree</a></li>
<li><a href="Self-balancing_binary_search_tree" title="Self-balancing binary search tree">Self-balancing tree</a></li>
<li><a href="Splay_tree" title="Splay tree">Splay tree</a></li></ul></li>
<li>
<ul><li><a href="Binary_heap" title="Binary heap">Binary heap</a></li>
<li><a href="Binomial_heap" title="Binomial heap">Binomial heap</a></li>
<li><a href="Fibonacci_heap" title="Fibonacci heap">Fibonacci heap</a></li></ul></li>
<li><a href="R-tree" title="R-tree">R-tree</a>
<ul><li><a href="R*_tree" class="mw-redirect" title="R* tree">R* tree</a></li>
<li><a href="R%2B_tree" title="R+ tree">R+ tree</a></li>
<li><a href="Hilbert_R-tree" title="Hilbert R-tree">Hilbert R-tree</a></li></ul></li>
<li><a href="Trie" title="Trie">Trie</a>
<ul><li><a href="Hash_tree_(persistent_data_structure)" title="Hash tree (persistent data structure)">Hash tree</a></li></ul></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Graph_(abstract_data_type)" title="Graph (abstract data type)">Graphs</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Binary_decision_diagram" title="Binary decision diagram">Binary decision diagram</a></li>
<li><a href="Directed_acyclic_graph" title="Directed acyclic graph">Directed acyclic graph</a></li>
<li><a href="Deterministic_acyclic_finite_state_automaton" title="Deterministic acyclic finite state automaton">Directed acyclic word graph</a></li></ul>
</div></td></tr><tr><td class="navbox-abovebelow" colspan="2"><div>
<ul><li><a href="List_of_data_structures" title="List of data structures">List of data structures</a></li></ul>
</div></td></tr></tbody></table></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-07-12" href="https://en.wikipedia.org/wiki/?title=Heap_(data_structure)&oldid=1300138188">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>